import { UiButton } from "@/shared/Uikit";
import { UiSelectField } from "@/shared/Uikit/UiSelectField";
import { UiTextField } from "@/shared/Uikit/UiTextField";
import { useGetCurrentUser } from "@/entities/user/model/useGetCurrentUser";
import { useRemoveTheme } from "../model/useRemoveTheme";
import { useGetAllThemes } from "@/entities/theme/model/useGetAllThemes";
import { useEffect } from "react";

type RemoveThemeFormProps = {
    onSuccess?: () => void
    themeId: number
}

export default function UiRemoveThemeForm(props: RemoveThemeFormProps) {
    const { handleSubmit, errorMessage, isSuccess } = useRemoveTheme(props.themeId)
    const { user } = useGetCurrentUser();
    const { themes } = useGetAllThemes()

    useEffect(() => {
        if (isSuccess && props.onSuccess) props.onSuccess()
    }, [isSuccess,props.onSuccess])

    return (
        <div className='flex flex-col gap-4'>
            <h1 className='font-bold text-lg'>Удалить тему:</h1>
            <form className="flex flex-col gap-2" onSubmit={handleSubmit}>
                <UiButton variant="primary">
                    Удалить.
                </UiButton>
                {errorMessage && <div className="text-rose-500">{errorMessage}</div>}
                {isSuccess && <div className="text-green-500">Успешно!</div>}
            </form>
        </div>
    )
}